import {getGoods,goodsType} from '../api/goods'
export default{
    state:{
        goods:[],
        goodstype:[]
    },
    effects:{
        *getGoodsSaga({payload},{put,call}){
            // console.log(111);
            const res=yield call(getGoods,payload)
            // console.log('saga获取数据',res);
            yield put({type:'initGoods',payload:res.rows})
        },
        *goodstypeSaga({payload},{put,call}){
            const res=yield call(goodsType,payload)
            // console.log('saga获取商品类型数据',res.rows.children);
            yield put({type:'initGoodsType',payload:res.rows.children})
        }
    },
    reducers:{
        initGoods(state,action){
            state.goods = action.payload
        },
       initGoodsType(state,action){
        state.goodstype = action.payload
       }
    }
}